Programming and uploading Arduino sketch without IDE

arduino-mk package makes it simple to build and upload sketches on a Raspberry Pi without the bloated Arduino IDE.

Install the package:

sudo apt-get install arduino-mk

This will install all the required software and files.

Create a library area in your user home directory with a demo sketch in it:

mkdir ~/sketchbook
cd ~/sketchbook
ln -s /usr/share/arduino/Arduino.mk
mkdir blink
cd blink
sudo nano blink.ino

// Blink

void setup(void) {
  pinMode(13, OUTPUT);
}

void loop() {
  digitalWrite(13, LOW);
  delay(1000);
  digitalWrite(13, HIGH);
  delay(1000);
}

Save it.

Create the Makefile:

sudo nano Makefile

BOARD_TAG = leonardo
ARDUINO_PORT = /dev/ttyACM0
ARDUINO_LIBS =
ARDUINO_DIR = /usr/share/arduino
include ../Arduino.mk
make
make upload

It will prepare the c and bit files and burn the memory on your Arduino. Watch your LED blinks.

Other commands to perform various tasks:

make – no upload
make upload – compile and upload
make clean – remove all our dependencies
make depends – update dependencies
make reset – reset the Arduino by tickling DTR on the serial port
make raw_upload – upload without first resetting
make show_boards – list all the boards defined in boards.txt

(Visited 8,177 times, 1 visits today)

8 thoughts on “Programming and uploading Arduino sketch without IDE”

  1. ionut says:

    i get a error on make/make upload? why? there are other seting that i should make?

    1. Linux Circle says:

      What is the error message?

      Store your make file and your .ino file in the same folder and
      make sure you have Arduino.mk file somewhere near your working directory, so you can include it like this in your make file:
      include ../Arduino.mk
      assuming that the file is in your parent folder.

      1. ionut says:

        i did exaclli as you said, i try to upload a android bluetooth code… if i try to upload id from my pc it works…if i try to upload from pi i get a fatal error… meetandroid.h no such file or directory… if i try to upload an linefollower code same thing… 535.. luid-cli/depends.mk: no such file…..

      2. Dipto Pratyaksa Dipto Pratyaksa says:

        Hi, you must import all Android libraries, and point the right path in your make file.
        It seems that meetandroid.h does not exist or the path to it is not found.

      3. Dipto Pratyaksa Dipto Pratyaksa says:

        ionut, this is my Makefile. I am using Gertboard, but you can use any Arduino compatible board. Just have to find the right name for the BOARD_TAG

        BOARD_TAG = gert328
        ARDUINO_PORT = /dev/ttyS1
        #ARDUINO_LIBS = /usr/share/arudino/libraries
        ARDUINO_DIR = /usr/share/arduino
        #ARDMK_DIR = /usr/bin
        #AVR_TOOLS_DIR =/usr/share/arduino/hardware/tools

        include ../Arduino.mk

      4. ionut says:

        i am using arduino uno..what is the bord tag for it? uno?

      5. Look for the file for the right tag: /arduino-1.0/ hardware/arduino/boards.txt

        Default boards.txt can be found here: http://arduino.cc/en/uploads/Main/boards.txt

        uno is there. You can also add your board into the list if not already listed

        ##############################################################

        uno.name=Arduino Uno
        uno.upload.protocol=stk500
        uno.upload.maximum_size=32256
        uno.upload.speed=115200
        uno.bootloader.low_fuses=0xff
        uno.bootloader.high_fuses=0xde
        uno.bootloader.extended_fuses=0x05
        uno.bootloader.path=optiboot
        uno.bootloader.file=optiboot_atmega328.hex
        uno.bootloader.unlock_bits=0x3F
        uno.bootloader.lock_bits=0x0F
        uno.build.mcu=atmega328p
        uno.build.f_cpu=16000000L
        uno.build.core=arduino

  2. Tomas says:

    ARDUINO_LIBS is not path! but libraries (include you have in ino) separate by spaces..

Comments are closed.